﻿using System.IO;
using System.Reflection;
using FitNesseRunner.Model;

namespace FitNesseRunner
{
	internal class AssemblyLoader : IAssemblyLoader
	{
		public void LoadAssembliesFrom(string classPath)
		{
			//if (!Path.IsPathRooted(classPath))
				//classPath = Path.Combine(Directory.GetCurrentDirectory(), classPath);

			var directory = Path.GetDirectoryName(classPath);
			var filenameOrPattern = Path.GetFileName(classPath);
			var allFiles = Directory.GetFiles(directory, filenameOrPattern);
			foreach (var file in allFiles)
			{
				Assembly.LoadFrom(file);
			}
		}
	}
}